package com.gexin.model.activity;

import com.gexin.model.activity.base.BaseMemberOrderIntegral;

import java.lang.reflect.Member;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.zip.DataFormatException;


/**
 * 业务名称:  t_member_order_integral() 
 */
@SuppressWarnings("serial")
public class MemberOrderIntegral extends BaseMemberOrderIntegral<MemberOrderIntegral> {
	public static final MemberOrderIntegral dao = new MemberOrderIntegral();

	public void setUserIdAndBillAndItemIdAndStatus(
			String id,String userId,BigDecimal bill,String itemId, BigDecimal magnification,int status
	){

			this.setUserId(userId);
			this.setBillIntegral(bill);
			this.setOrderItemId(itemId);
			this.setStatus(status);

		this.setId(id);
		this.setUserId(userId);
		this.setBillIntegral(bill);
		this.setOrderItemId(itemId);
		this.setMagnification(magnification);
		this.setStatus(status);
		long date = new Date().getTime();
		this.setCreateTime(date);
		this.setUpdateTime(date);

	}

	public List<MemberOrderIntegral>  getMemberOrderList(){
		List<MemberOrderIntegral> memberOrderIntegrals = MemberOrderIntegral.dao.find("select * from t_member_order_integral for update");
		return memberOrderIntegrals;
	}
	public List<MemberOrderIntegral>  getMemberOrder(){
		List<MemberOrderIntegral> memberOrderIntegrals = MemberOrderIntegral.dao.find("select * from t_member_order_integral where status=2");
		return memberOrderIntegrals;
	}

	public  MemberOrderIntegral   getMemberOrderByItemId(String itemId){
		MemberOrderIntegral  memberOrderIntegrals = MemberOrderIntegral.dao.findFirst("select * from t_member_order_integral where status=2" +
				" and user_id="+itemId);
		return memberOrderIntegrals;
	}

	public List<MemberOrderIntegral>  getMemberOrderByUserId(String userId){
		List<MemberOrderIntegral> memberOrderIntegrals = MemberOrderIntegral.dao.find("select * from t_member_order " +
				"where status=2 or status=6 and user_id="+userId + " order by create_time desc");
		return memberOrderIntegrals;
	}

	public List<MemberOrderIntegral> getMemberOrderIntegralList(String  orderId){
		List<MemberOrderIntegral> memberOrderIntegrals = MemberOrderIntegral.dao.find("select * from t_member_order_integral " +
				"where status=2 or status=6 and order_id="+orderId);
		return memberOrderIntegrals;
	}

	public List<MemberOrderIntegral> findByOrderIdByStatus(String orderId,int status) {
		List<MemberOrderIntegral> memberOrderIntegrals = MemberOrderIntegral.dao.find("select * from t_member_order_integral " +
				"where status=" + status + " and order_id="+orderId);
		return memberOrderIntegrals;
	}


//	public BigDecimal dailyIncrement = this.getDailyIncrement() == null ?  new BigDecimal("0") : this.getDailyIncrement();
}
